package com.tedu.egmybatis1.mapper;

import com.tedu.egmybatis1.pojo.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Insert("INSERT INTO product(title,price,stock)\n"+
    "VALUES(#{title},#{price},#{stock})")
    int insert(Product product);
   /* @Select("SELECT id,title,price,stock\n"+
    "FROM product\n"+
    "WHERE id = #{id}")
    Product selectSingleProduct(Integer id);*/
    @Delete("DELETE FROM product WHERE id = #{id}")
    int deleteById(Integer id);
    @Select("SELECT id,title,price,stock\n"+
    "FROM product\n")
    List<Product> selectManyProduct();
    @Update("UPDATE product\n"+
    "SET title=#{title},price=#{price},stock=#{stock}\n"+
    "WHERE id = #{id}")
    int updateById(Product product);
    @Select("SELECT id,title,price,stock\n"+
    "FROM product\n"+
    "WHERE id = #{id}")
    Product selectById(Integer id);
}
